package com.qiyu.jvm.stack;

/**
 * 测试栈中的内存溢出异常
 * -Xss250k 7509 1442
 * @Author linhao
 * @Date created in 2:59 下午 2021/1/3
 */
public class StackOverMemoryError {

    private int stackLength = 1;

    public void stackLeak(){
        long a1,a2,a3,a4,a5,s6,a7,a8,a9,a10,
                a11,a12,a13,a14,a15,a16,a17,a18,a19,
                a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30;
        stackLength++;
        stackLeak();
    }

    public static void main(String[] args) {
        System.out.println("测试 栈溢出 情况");
        StackOverMemoryError stackOverMemoryError = new StackOverMemoryError();
        try {
            stackOverMemoryError.stackLeak();
        }catch (Throwable e){
            System.out.println(stackOverMemoryError.stackLength);
            e.printStackTrace();
        }
    }
}
